NexusFi: Find Your Edge


Home Menu

 





BarsSinceEntry para orden short o long


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,933 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
crismont
Ecuador, esmeraldas , tonsupa
 
Posts: 2 since Apr 2020
Thanks Given: 1
Thanks Received: 0

Hello community of traders.

I am new to Easylanguage. I have problems in my code when I want to use the reserved word BarsSinceExit, in my strategy I want to launch a purchase order after 10 bars of having closed a position, when I uncertain that I do this for a long order it executes it correctly but when it is uncertain in the short order it does not and no long or short order appears, that is, the BarsSinceEntry only works for a long order or a short order but not for both simultaneously.

I do not know what I am doing wrong, I attach my code so please indicate to me what I am doing wrong or give me another alternative to get me to enter a position after having closed (10 or 9 or 5) bars behind.



input: DesicionBarintervalexit (10)

if close > high [1] and Barssinceexit (1) >= DesicionBarintervalexit then
BUY ("B1") next bar at market;
end;

if close < high [1] and BarsSinceEntry (1) >= DesicionBarintervalentry then
SELLSHORT ("S1") next bar market;

I await your comments, thank you in advance to all who can help me.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Strategy runs differently with in Automated Order Execut …
MultiCharts
Half-life over Cointegration?
Traders Hideout
Tradestation Chart Setup
TradeStation
NT TopStep discount?
NinjaTrader
Requesting replay data for...
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Algo automated / semi-automated trading anyone?
22 thanks
Statistical Arbitrage trading/market neutral strategies
13 thanks
Any good traders on YouTube?
12 thanks
Tariffs and what comes next...
5 thanks
Daytrading ES & NQ
4 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

crismont,

one pitfall could be that Barssinceexit (1) and BarsSinceEntry (1) will only carry a value after there was at least one entry/exit. So your code might not be able to enter at all and you need to deal with the special case of the first entry on the chart. How you do this is up to you and one idea could be to use ( Barssinceexit (1) >= DesicionBarintervalexit or TotalTrades = 0 ) to allow the first long entry.

Regards,

ABCTG


Follow me on X Reply With Quote
Thanked by:
  #3 (permalink)
 
bobb's Avatar
 bobb 
near Vienna Austria
 
Experience: Intermediate
Platform: TradeStation, MultiCharts
Trading: Stocks, Forex
Posts: 6 since Apr 2012
Thanks Given: 1
Thanks Received: 1


You can try this one

{ Exit at N bars since entry }

Input: NBEnt(3);

If MarketPosition = 1 and BarsSinceEntry = NBEnt then
Sell next bar at market;

If MarketPosition = -1 and BarsSinceEntry = NBEnt then
Buy to cover next bar at market;


Hope it helps


Reply With Quote




Last Updated on May 3, 2020


© 2025 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts