Tie one system to another

Questions about MultiCharts and user contributed studies.
User avatar
virginiatrader
Posts: 79
Joined: 05 May 2007
Location: Virginia
Has thanked: 5 times
Been thanked: 5 times

Tie one system to another

Postby virginiatrader » 01 Aug 2011

Howdy all!

I have coded a simple trend system, consisting of a long term moving average element with a breakout element based on weekly end-of-day data, and a "close of data1/close of data2" chart showing the trade executions on the daily data.

But I have hit a sticky point. The system executes a "coverBuy" or "coverSell" based on a pullback or rally of N-weeks. In reviewing the trades, I have found that the price reversed and closed at an N-week HIGH or LOW after the covering trades, and began a new, strong trend before the long term system signaled another entry.

I cannot figure out how to incorporate the N-week "price-reversal-after-the-cover-trade" signal.

Any and all guidance and opinions are appreciated in advance.

virginiatrader
Attachments
Cotton with Buys and coverBuy.png
Cotton with Buys and coverBuy.png (49.39 KiB) Viewed 161 times

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Tie one system to another

Postby TJ » 01 Aug 2011

virginiatrader wrote:Howdy all!

I have coded a simple trend system, consisting of a long term moving average element with a breakout element based on weekly end-of-day data, and a "close of data1/close of data2" chart showing the trade executions on the daily data.

But I have hit a sticky point. The system executes a "coverBuy" or "coverSell" based on a pullback or rally of N-weeks. In reviewing the trades, I have found that the price reversed and closed at an N-week HIGH or LOW after the covering trades, and began a new, strong trend before the long term system signaled another entry.

I cannot figure out how to incorporate the N-week "price-reversal-after-the-cover-trade" signal.

Any and all guidance and opinions are appreciated in advance.

virginiatrader


not sure what you are trying to achieve.
can you post your codes?

you really should start with a flow-chart... with step-by-step instruction clearly described at each branch.

User avatar
virginiatrader
Posts: 79
Joined: 05 May 2007
Location: Virginia
Has thanked: 5 times
Been thanked: 5 times

Re: Tie one system to another

Postby virginiatrader » 02 Aug 2011

As requested:

[IntrabarOrderGeneration = true]
inputs: lengthTrendAvg(52), lengthBreakout(13), lengthClose(4);
{***************************************************************************************}
if xaverage(close of data2,lengthTrendAvg) > xaverage(close of data2,lengthTrendAvg) [1]
then begin
if close of data2 > highest(high of data2,lengthBreakout) [1]
then buy ("CS4LE") 1 contracts next bar at Open;
end;
{***************************************************************************************}
if close of data2 < lowest(close of data2,lengthClose) [1]
and close > open
then sell ("coverBuy") next bar at Open;
{***************************************************************************************}
if xaverage(close of data2,lengthTrendAvg) < xaverage(close of data2,lengthTrendAvg) [1]
then begin
if close of data2 < lowest(low of data2,lengthBreakout) [1]
then sellshort ("CS4SE") 1 contracts next bar at Open;
end;
{***************************************************************************************}
if close of data2 > highest(close of data2,lengthClose) [1]
and close < open
then buytocover ("coverSell") next bar at Open;
{***************************************************************************************}

Will give the flowchart a try!

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Tie one system to another

Postby TJ » 02 Aug 2011

please use code tag when posting codes. It makes reading codes easier.

I have added the tags for you below:


Code: Select all

[IntrabarOrderGeneration = true]
inputs: lengthTrendAvg(52), lengthBreakout(13), lengthClose(4);
{***************************************************************************************}
if xaverage(close of data2,lengthTrendAvg) > xaverage(close of data2,lengthTrendAvg) [1]
   then begin   
   if close of data2 > highest(high of data2,lengthBreakout) [1]
         then buy ("CS4LE") 1 contracts next bar at Open; 
   end;
{***************************************************************************************}
if close of data2 < lowest(close of data2,lengthClose) [1]
   and close > open
         then sell ("coverBuy") next bar at Open;
{***************************************************************************************}
if xaverage(close of data2,lengthTrendAvg) < xaverage(close of data2,lengthTrendAvg) [1]
   then begin   
   if close of data2 < lowest(low of data2,lengthBreakout) [1]
         then sellshort ("CS4SE") 1 contracts next bar at Open;
   end;                                       
{***************************************************************************************}
if close of data2 > highest(close of data2,lengthClose) [1]
   and close < open
              then buytocover ("coverSell") next bar at Open;
{***************************************************************************************}

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Tie one system to another

Postby TJ » 02 Aug 2011

p.s.

Code: Select all

xaverage(close of data2,lengthTrendAvg)

should be written as

xaverage(close, lengthTrendAvg) of data2


see post #5
viewtopic.php?f=16&t=6929

User avatar
virginiatrader
Posts: 79
Joined: 05 May 2007
Location: Virginia
Has thanked: 5 times
Been thanked: 5 times

Re: Tie one system to another

Postby virginiatrader » 02 Aug 2011

Thanks, sir. The modification you recommended changes the results of the Performance Summary slightly. Also, thanks for the heads-up about the code tags...didn't know.

Still working on the flow chart. I can see what I want to accomplish in my head, just not sure how to code it.

virginiatrader


Return to “MultiCharts”