NexusFi: Find Your Edge


Home Menu

 





EasyLanguage one trade a day


Discussion in MultiCharts

Updated
      Top Posters
    1. looks_one ABCTG with 7 posts (2 thanks)
    2. looks_two nimrodc with 6 posts (0 thanks)
    3. looks_3 kevinkdog with 1 posts (1 thanks)
    4. looks_4 SMCJB with 1 posts (2 thanks)
    1. trending_up 6,684 views
    2. thumb_up 5 thanks given
    3. group 5 followers
    1. forum 16 posts
    2. attach_file 0 attachments




 
Search this Thread

EasyLanguage one trade a day

  #1 (permalink)
nimrodc
israel
 
Posts: 7 since Jan 2018
Thanks Given: 3
Thanks Received: 0

Hi

i am using the following code to get only one trade a day but the simulation show few trades a day
what am i doing wrong ?

thanks

variables:
tradesCounter(0);

[IntraBarOrderGeneration = TRUE]
If Date <> Date[1] then begin
tradesCounter = 0;
end;

If (marketposition (0) = 0) and (tradesCounter < 1)then begin
Buy ("BUY-LONG") next bar at market;
end;
If marketposition (0) <> 0 then begin
Sell ("STOPLOSS") next bar at EntryPrice - 0.5;
end;
If ( Marketposition(0) <> 0 ) and (Marketposition(1) <> Marketposition(0) ) then tradesCounter = tradesCounter+ 1;
Setexitonclose;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

nimrodc,

welcome to futures.io. I would suggest to use the Print reserved to check the value that tradesCounter has throughout your code. This will help you in tracking the problem down.
I would also suggest checking (again the print reserved word can be helpful) when your conditional statement "If ( Marketposition(0) <> 0 ) and (Marketposition(1) <> Marketposition(0) )" is true.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #3 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,049 since Dec 2013
Thanks Given: 4,386
Thanks Received: 10,206


Or, put the counter inside the loop that gets you into the first trade.

 
Code
variables: tradesCounter(0);

[IntraBarOrderGeneration = TRUE]

If Date <> Date[1] then tradesCounter = 0;

If (marketposition = 0 and tradesCounter = 0) then begin 
    Buy ("BUY-LONG") next bar at market;
    tradesCounter = 1
end;

If marketposition = 1 then Sell ("STOPLOSS") next bar at EntryPrice - 0.5 Stop;

Reply With Quote
Thanked by:
  #4 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,663 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,357

Or use EntriesToday reserved word.

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
nimrodc
israel
 
Posts: 7 since Jan 2018
Thanks Given: 3
Thanks Received: 0

thanks all for the replies
i tried this option but still get multiple entries per day in the simulation

does any one have similar code that is tested/works for him

thanks

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

nimrodc,

the code @SMCJB posted should not take more than one trade per date.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #7 (permalink)
nimrodc
israel
 
Posts: 7 since Jan 2018
Thanks Given: 3
Thanks Received: 0


ABCTG View Post
nimrodc,

the code @SMCJB posted should not take more than one trade per date.

Regards,

ABCTG

thanks
i tried it but it didnt work for me...
when debugging the code i saw that

If Date <> Date[1] then tradesCounter = 0;

tradesCounter is set back to 0 although the date didnt change
meaning a new date => tradesCounter is set to 0 then the Buy kicks in but then on next round although we still on same date tradesCounter is set to 0 again

anyone understands why ?

Reply With Quote
  #8 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

nimrodc,

I am not sure I follow you. The condition "Date <> Date[1]" is only true for two bars that have a different date.

As the code @SMCJB posted is using Intrabar Ordergeneration the tradeCounter variable should be declared as intrabarpersist. Otherwise it won't hold its value between the ticks.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #9 (permalink)
nimrodc
israel
 
Posts: 7 since Jan 2018
Thanks Given: 3
Thanks Received: 0


ABCTG View Post
nimrodc,

I am not sure I follow you. The condition "Date <> Date[1]" is only true for two bars that have a different date.

As the code @SMCJB posted is using Intrabar Ordergeneration the tradeCounter variable should be declared as intrabarpersist. Otherwise it won't hold its value between the ticks.

Regards,

ABCTG


the code for declaration was

variables: tradesCounter(0);

anything i am missing or need to add to this so it will be intrabarpersist ?

Reply With Quote
  #10 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


nimrodc,

yes, by default the variable will not be intrabarpersist. This has to be added specifically for each variable.
You can read more about it here: https://community.tradestation.com/wiki/display/EasyLanguage/IntrabarPersist

Regards,

ABCTG


nimrodc View Post
the code for declaration was

variables: tradesCounter(0);

anything i am missing or need to add to this so it will be intrabarpersist ?


Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on January 12, 2021


© 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