NexusFi: Find Your Edge


Home Menu

 





BarsSinceEntry para orden short o long


Discussion in EasyLanguage Programming

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




 
Search this Thread

BarsSinceEntry para orden short o long

  #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?
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

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 Twitter 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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts