NexusFi: Find Your Edge


Home Menu

 





BarsSinceEntry para orden short o long


Discussion in EasyLanguage Programming

Updated
    1. trending_up 2,354 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?
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
TradingView Deploys AI to Monitor SEC Filings in Real Ti …
TradingView
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
Orban at 29pct as Hungary Votes Tomorrow -- McIlroy Surg …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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


© 2026 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