NexusFi: Find Your Edge


Home Menu

 





Trades count


Discussion in EasyLanguage Programming

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




 
Search this Thread

Trades count

  #1 (permalink)
soacm
Bucharest, Romania
 
Posts: 71 since Mar 2022
Thanks Given: 38
Thanks Received: 22

Hi, I would like to stop my strategy from trading if X happens. e.g, if the High of the previous day is violated before the specified time window, I do not want to take any trade during that specific day.
I tried the following solution without any result:
 
Code
//15-minute chart and Daily as Data2 
 
input: StartTime(200); 
 
var: ET(0); 
      ET = Entriestoday(date[0]); 
       if close > High[1] of Data2 and Time < StartTime then ET = 1 // increase Entriestoday(date[0]) by 1 if that happened before 2am 
  
// Entry 
 
if Entriestoday(date[0]) < 1 and Time > StartTime then // if the previous daily high was not violated, Entriestoday(date[0]) should be < 1 hence take the trade 
{insert entry rules};
Let me know, thank you.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
26 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #2 (permalink)
 
syswizard's Avatar
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
Posts: 344 since Jan 2019
Thanks Given: 20
Thanks Received: 146


soacm View Post
ET = Entriestoday(date[0]);

Where did you find out about EntriesToday ? It's not in the MC Wiki, not in the Powerlanguage PDF either.

Reply With Quote
  #3 (permalink)
soacm
Bucharest, Romania
 
Posts: 71 since Mar 2022
Thanks Given: 38
Thanks Received: 22



syswizard View Post
Where did you find out about EntriesToday ? It's not in the MC Wiki, not in the Powerlanguage PDF either.

TradeStation

Reply With Quote
  #4 (permalink)
 
syswizard's Avatar
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
Posts: 344 since Jan 2019
Thanks Given: 20
Thanks Received: 146


soacm View Post
TradeStation

Ah....it's not in Multicharts. Sorry, can't help you then.

Reply With Quote
Thanked by:
  #5 (permalink)
soacm
Bucharest, Romania
 
Posts: 71 since Mar 2022
Thanks Given: 38
Thanks Received: 22


syswizard View Post
Ah....it's not in Multicharts. Sorry, can't help you then.

Any solution is fine as long as it does the same job.

Reply With Quote
  #6 (permalink)
 
syswizard's Avatar
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
Posts: 344 since Jan 2019
Thanks Given: 20
Thanks Received: 146

You could use "TotalTrades" if your Instrument settings are set for the current day only.

Otherwise, you must roll your own since the built-in function is not working.

Vars:
vMP(0)
,cCntr(0)
;
vMP = MarketPosition;

If Time > Sess1FirstBarTime and Time[1] < Sess1FirstBarTime Then
vCntr = Iff(vMP <>0,1,0); ///initialize at start of trading

vCntr = Iff(vMP <> vMP[1],vCntr+1,vCntr); // increment if a new position is taken


So put this into a function and return the vCntr variable value.

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

if the High of the previous day is violated before the specified time window, I do not want to take any trade during that specific day.



input: timew(1000);
var: CanTrade(True);


if date<>date[1] then CanTrade=True; //resets at midnight every new day

If high>close[1] of data2 and time<timew then CanTrade=False;


If CanTrade and {your criteria} then buy next bar at market;

Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
soacm
Bucharest, Romania
 
Posts: 71 since Mar 2022
Thanks Given: 38
Thanks Received: 22


kevinkdog View Post
if the High of the previous day is violated before the specified time window, I do not want to take any trade during that specific day.



input: timew(1000);
var: CanTrade(True);


if date<>date[1] then CanTrade=True; //resets at midnight every new day

If high>close[1] of data2 and time<timew then CanTrade=False;


If CanTrade and {your criteria} then buy next bar at market;

Thank you for your replies; @kevinkdog I thought it was the right solution, but still, it executes the trade.

Tried to use Totaltrades which stopped executing the trades after the previous high was violated but stopped executing even other trades that were respecting the rules:

 
Code
input: StartTime(200);
var: TT(0);

if Date <> Date[1] then 
TT = 0;

if Close > High[1] of Data2 and Time < StartTime then TT = 1;

if TT = 0 then 
{insert entry rules};
Any other suggestions?

Reply With Quote
  #9 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,664 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,358

I would use print statements to debug what I wrote. It could be that close[1] of data2 is not what you think.

Follow me on Twitter Reply With Quote
  #10 (permalink)
soacm
Bucharest, Romania
 
Posts: 71 since Mar 2022
Thanks Given: 38
Thanks Received: 22



kevinkdog View Post
I would use print statements to debug what I wrote. It could be that close[1] of data2 is not what you think.

It worked, thank you Kevin.

Reply With Quote




Last Updated on August 21, 2022


© 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