NexusFi: Find Your Edge


Home Menu

 





Resetting Variables in MC Signal


Discussion in MultiCharts

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




 
Search this Thread

Resetting Variables in MC Signal

  #1 (permalink)
 reticent67 
Los Angeles
 
Experience: Intermediate
Platform: Sierra Chart
Trading: Stocks
Posts: 6 since Jun 2012
Thanks Given: 1
Thanks Received: 0

Hi All,

I've been lurking on this forum for a few months now, but this is my first post so... Hi!


I'm not a programmer and after a few months of getting frustrated with C#, I decided to switch from NinjaTrader to MC (demo only at this point). I've read most of the Wiki (not very helpful) and have searched but haven't been able to find a clear answer.

Anyway, I'm trying to get my NT strategy coded into MC. I have a bool variable that gets set to true when one indicator reaches a value. Then if that bool is true and my second indicator reaches its value, a sell is triggered.

The problem is that in Ninja, I used the OnOrderExecution method to reset my bool variable to false whenever I entered a trade. But now in MC, my variable is not getting reset and giving me the wrong exits.

So, how exactly do I go about resetting my variable once I enter my position in MC?

Thanks in advance.
Rick

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
23 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #2 (permalink)
Bimi
London
 
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58


reticent67 View Post
Hi All,

I've been lurking on this forum for a few months now, but this is my first post so... Hi!


I'm not a programmer and after a few months of getting frustrated with C#, I decided to switch from NinjaTrader to MC (demo only at this point). I've read most of the Wiki (not very helpful) and have searched but haven't been able to find a clear answer.

Anyway, I'm trying to get my NT strategy coded into MC. I have a bool variable that gets set to true when one indicator reaches a value. Then if that bool is true and my second indicator reaches its value, a sell is triggered.

The problem is that in Ninja, I used the OnOrderExecution method to reset my bool variable to false whenever I entered a trade. But now in MC, my variable is not getting reset and giving me the wrong exits.

So, how exactly do I go about resetting my variable once I enter my position in MC?

Thanks in advance.
Rick

are you using market orders?
you can simply add a line after your order (within the same conditional block):

 
Code
if bool1 = true and bool2 = true then begin

     sell....

     bool1 = false;
     bool2 = false;

end;

Reply With Quote
  #3 (permalink)
 reticent67 
Los Angeles
 
Experience: Intermediate
Platform: Sierra Chart
Trading: Stocks
Posts: 6 since Jun 2012
Thanks Given: 1
Thanks Received: 0


Thank you for the response, Bimi.

Unfortunately that doesn't give the required result. The problem (I think) is that I have multiple entry order conditions and they keep overriding the bool variable during the trade. No matter where I put the "bool = false;" statement, I keep getting the wrong results. I had this same problem with Ninja until I reset the variables in the OnOrderExecution section.

Here is my code, maybe someone can take a look and tell me where I need to put my reset to get the desired result:

By the way, this signal is only for URTY or TNA. It backtested 77% profitable with a .73 Sharpe Ratio (in NinjaTrader) so feel free to try it out.

 
Code
inputs:
	DS_Period(3),
	DS_Smoothing(3),
	MoLength(13),
	Overbought(76),
	Oversold(22);
	
	
vars:
	DSVal(0),
	MoVal(0),
	okSell(false),
	uptrend(false),
	downtrend(false),
	wmaV(0),
	ema1V(0),
	ema2V(0);
	
	
DSVal = DoubleStochastics(DS_Period, DS_Smoothing);
MoVal = Momentum(Close, MoLength);
wmaV  = WAverage(Close, 13);
ema1V = XAverage(Close, 13);
ema2V = XAverage((High + Low) / 2, 13);

{Check For Trend}
//Uptrend//
if Open > wmaV and Close > wmaV  and wmaV > ema1V and ema1V > ema2V then 
	uptrend = True
	else uptrend = false;
	

	

{Entry Order Management}
//Normal Entry
if marketposition = 0 and DSVal[1] < Oversold then begin
	Buy ("Normal Entry") next bar at market;
end;

//Uptrend Entry

if uptrend  then begin
	if marketposition = 0 and barssinceexit(1) >= 1 and DSVAL > DSVal[1] then
		Buy ("Uptrend Entry") next bar at market;
end;



{Set The Sell Trigger Variable}
if marketposition = 1 and DSVal crosses above Overbought then begin
		okSell = true;
end;


{Exit Order Management}

//Normal Exit	
if marketposition = 1 and OkSell and MoVal < MoVal[1] then begin
	Sell ("Normal Exit") from Entry ("Normal Entry") next bar at Market;
	okSell = false;
end;

//Trend Exit
if marketposition = 1 and barssinceentry(0) >= 1 and okSell and MoVal < MoVal[1] then begin
	Sell ("Down Day") from Entry ("Uptrend Entry") next bar at Market;
	okSell = false;
	
end;

//Uptrend Ends Mid-Trade
if marketposition = 1 and Close < wmaV or Open < wmaV or ema1V crosses below ema2V then
	Sell ("Uptrend End") From Entry ("Uptrend Entry") next bar at market;

Started this thread Reply With Quote
  #4 (permalink)
Bimi
London
 
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58

do you have the function DoubleStochastics?

Reply With Quote
  #5 (permalink)
 reticent67 
Los Angeles
 
Experience: Intermediate
Platform: Sierra Chart
Trading: Stocks
Posts: 6 since Jun 2012
Thanks Given: 1
Thanks Received: 0


Quoting 
do you have the function DoubleStochastics?

Yes, I do. And the entries are working as expected. It's just the exits that are in the wrong place.

Started this thread Reply With Quote
  #6 (permalink)
Bimi
London
 
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58

is this the complete strategy?
it does not look complete.
when you reset your logic, you have to follow the flow, and reset at the specific juncture, and the flow seem something is missing.

Reply With Quote
  #7 (permalink)
Bimi
London
 
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58

What is the chart resolution you are using? Daily? hourly?

Reply With Quote
  #8 (permalink)
 reticent67 
Los Angeles
 
Experience: Intermediate
Platform: Sierra Chart
Trading: Stocks
Posts: 6 since Jun 2012
Thanks Given: 1
Thanks Received: 0

For the most part, yes. This the complete strategy. It's meant to be the first half of a pair trade with SRTY (or TZA in the case of TNA). It's a swing trade run on daily bars. Basically, I'm optimizing this half because it is the most profitable. In the end, it will pretty much be "go long SRTY when you're not long URTY."

I have no stop loss or other risk measures because in all tests they have only hurt performance. The only thing left to implement is how to handle the trades during a downtrend as this really the only time I incur my biggest losses.

Started this thread Reply With Quote
  #9 (permalink)
Bimi
London
 
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58


reticent67 View Post
For the most part, yes. This the complete strategy. It's meant to be the first half of a pair trade with SRTY (or TZA in the case of TNA). It's a swing trade run on daily bars. Basically, I'm optimizing this half because it is the most profitable. In the end, it will pretty much be "go long SRTY when you're not long URTY."

I have no stop loss or other risk measures because in all tests they have only hurt performance. The only thing left to implement is how to handle the trades during a downtrend as this really the only time I incur my biggest losses.

I would suggest you to double up on the filters , so that you can add a layer of protection on the conditionals.

Good luck.

Reply With Quote
  #10 (permalink)
 reticent67 
Los Angeles
 
Experience: Intermediate
Platform: Sierra Chart
Trading: Stocks
Posts: 6 since Jun 2012
Thanks Given: 1
Thanks Received: 0


Forgive my ignorance, I don't quite follow your meaning.

Are saying that I should add more confirmation (i.e. indicators) to my strategy or is there some sort of code that I should be implementing to increase reliability?

Thanks again for all your time and responses.

Started this thread Reply With Quote




Last Updated on November 2, 2012


© 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