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 9,635 views
    2. thumb_up 5 thanks given
    3. group 5 followers
    1. forum 16 posts
    2. attach_file 0 attachments




 
Search this Thread
  #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?
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
400 Million Barrels to Address Middle East Supply Disruption
Commodities
Khamenei Vetoes Uranium Transfer as Peace Odds Surge to …
Prediction Markets & Event Contracts
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

nimrodc,

welcome to NexusFi. 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 X Reply With Quote
  #3 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT Stellar & Tradestation
Broker: Primarily Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals, U308 and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,241 since Dec 2013
Thanks Given: 4,584
Thanks Received: 10,523


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,737 since Jul 2012
Thanks Given: 1,917
Thanks Received: 7,470

Or use EntriesToday reserved word.


Follow me on X 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,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

nimrodc,

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

Regards,

ABCTG


Follow me on X 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,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

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 X 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,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639


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 X Reply With Quote
Thanked by:




Last Updated on January 12, 2021


© 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