NexusFi: Find Your Edge


Home Menu

 





Noob alert! Query regarding entering variable


Discussion in MultiCharts

Updated
    1. trending_up 3,337 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 14 posts
    2. attach_file 2 attachments




 
Search this Thread

Noob alert! Query regarding entering variable

  #11 (permalink)
 saj1011 
London, United Kingdom
 
Experience: Intermediate
Platform: MetaTrader
Trading: EUR/USD
Posts: 20 since Feb 2014
Thanks Given: 2
Thanks Received: 4

Hi prob with code again, what is wrong? i copied it exactly from forum. gettin this error:

Study: "BM_MoneyMaker" (Signal)
Please wait ....
------ Compiled with error(s): ------
unverified function is used
line 51, column 7
causal study: jthma (Function)

code:

inputs:

smalength ( 200 ),

emalength ( 100 ),

hmalength ( 34 ),

target1 ( 12 ),

target2 ( 12 ),

target3 ( 20 ),

stopsize ( 12 ),

BE2 ( 0 ), // 0=false, 1=true

BE3 ( 0 ); // 0=false, 1=true



vars:

TickSize ( MinMove / PriceScale ),

smav ( 0 ),

emav ( 0 ),

hmav ( 0 ),

t1 ( Target1 * TickSize ),

t2 ( (Target1 + Target2) * TickSize ),

t3 ( (Target1 + Target2 + Target3) * TickSize ),

st1 ( 0 ),

st2 ( 0 ),

st3 ( 0 );



smav = Average(Close, smalength);

emav = XAverage(Close, emalength);

hmav = jtHMA(Close, hmalength);





// open new positions



if MarketPosition = 0 then begin



if smav > smav[1] and emav > emav[1] and hmav > hmav[1] then begin



Buy ("Enter long") 3 Contracts Next Bar At Market;



end;



if smav < smav[1] and emav < emav[1] and hmav < hmav[1] then begin



SellShort ("Enter short") 3 Contracts Next Bar At Market;



end;

end;



// manage open orders



if MarketPosition = 1 then begin



st1 = EntryPrice - (stopsize * TickSize);

st2 = iff(BE2 = 1, EntryPrice, EntryPrice - (stopsize * TickSize));

st3 = iff(BE3 = 1, EntryPrice, EntryPrice - (stopsize * TickSize));



if CurrentContracts = 1 then begin

Sell ("Exit l3-c1 Target") 1 Contracts Next Bar At (EntryPrice + t3) Limit;

Sell ("Exit l3-c1 Stop") 1 Contracts Next Bar At st3 Stop;

end;



if CurrentContracts = 2 then begin

Sell ("Exit l2-c2 Target") 1 Contracts Next Bar At (EntryPrice + t2) Limit;

Sell ("Exit l2-c2 Stop") 1 Contracts Next Bar At st2 Stop;

Sell ("Exit l3-c2 Target") 1 Contracts Next Bar At (EntryPrice + t3) Limit;

Sell ("Exit l3-c2 Stop") 1 Contracts Next Bar At st3 Stop;

end;



if CurrentContracts = 3 then begin

Sell ("Exit l1-c3 Target") 1 Contracts Next Bar At (EntryPrice + t1) Limit;

Sell ("Exit l1-c3 Stop") 1 Contracts Next Bar At st1 Stop;

Sell ("Exit l2-c3 Target") 1 Contracts Next Bar At (EntryPrice + t2) Limit;

Sell ("Exit l2-c3 Stop") 1 Contracts Next Bar At st2 Stop;

Sell ("Exit l3-c3 Target") 1 Contracts Next Bar At (EntryPrice + t3) Limit;

Sell ("Exit l3-c3 Stop") 1 Contracts Next Bar At st3 Stop;

end;

end;



if MarketPosition = -1 then begin



st1 = EntryPrice + (stopsize * TickSize);

st2 = iff(BE2 = 1, EntryPrice, EntryPrice + (stopsize * TickSize));

st3 = iff(BE3 = 1, EntryPrice, EntryPrice + (stopsize * TickSize));



if CurrentContracts = 1 then begin

BuyToCover ("Exit s3-c1 Target") 1 Contracts Next Bar At (EntryPrice - t3) Limit;

BuyToCover ("Exit s3-c1 Stop") 1 Contracts Next Bar At st3 Stop;

end;



if CurrentContracts = 2 then begin

BuyToCover ("Exit s2-c2 Target") 1 Contracts Next Bar At (EntryPrice - t2) Limit;

BuyToCover ("Exit s2-c2 Stop") 1 Contracts Next Bar At st2 Stop;

BuyToCover ("Exit s3-c2 Target") 1 Contracts Next Bar At (EntryPrice - t3) Limit;

BuyToCover ("Exit s3-c2 Stop") 1 Contracts Next Bar At st3 Stop;

end;



if CurrentContracts = 3 then begin

BuyToCover ("Exit s1-c3 Target") 1 Contracts Next Bar At (EntryPrice - t1) Limit;

BuyToCover ("Exit s1-c3 Stop") 1 Contracts Next Bar At st1 Stop;

BuyToCover ("Exit s2-c3 Target") 1 Contracts Next Bar At (EntryPrice - t2) Limit;

BuyToCover ("Exit s2-c3 Stop") 1 Contracts Next Bar At st2 Stop;

BuyToCover ("Exit s3-c3 Target") 1 Contracts Next Bar At (EntryPrice - t3) Limit;

BuyToCover ("Exit s3-c3 Stop") 1 Contracts Next Bar At st3 Stop;

end;



end;



jtHMA function which i copied in separately:


{jtHMA - Hull Moving Average Function}

{Author: Atavachron}

{May 2005}



Inputs: price(NumericSeries), length(NumericSimple);

Vars: halvedLength(0), sqrRootLength(0);



{

Original equation is:

---------------------

waverage(2*waverage(close,period/2)-waverage(close ,period), SquareRoot(Period)

Implementation below is more efficient with lengthy Weighted Moving Averages.

In addition, the length needs to be converted to an integer value after it is halved and

its square root is obtained in order for this to work with Weighted Moving Averaging

}



if ((ceiling(length / 2) - (length / 2)) <= 0.5) then

halvedLength = ceiling(length / 2)

else

halvedLength = floor(length / 2);



if ((ceiling(SquareRoot(length)) - SquareRoot(length)) <= 0.5) then

sqrRootLength = ceiling(SquareRoot(length))

else

sqrRootLength = floor(SquareRoot(length));



Value1 = 2 * WAverage(price, halvedLength);

Value2 = WAverage(price, length);

Value3 = WAverage((Value1 - Value2), sqrRootLength);



jtHMA = Value3;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
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
  #12 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,627

saj1011,

when you post code, please wrap code tags around it. This helps a lot in the visibility.

When you say "jtHMA function which i copied in separately" did you copy it into the same signal code or did you create a separate function?

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #13 (permalink)
 saj1011 
London, United Kingdom
 
Experience: Intermediate
Platform: MetaTrader
Trading: EUR/USD
Posts: 20 since Feb 2014
Thanks Given: 2
Thanks Received: 4


separate function.

Started this thread Reply With Quote
  #14 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,627

saj1011,

I'll upload the code as PLA later, this should work fine then.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #15 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,627

saj1011,

here you go. This is the exact code like you posted it in this thread.
I did not test it or change it, just took what you posted and pasted it within the signal
and function, compiled it and exported it for you.

Regards,
ABCTG

Attached Files
Elite Membership required to download: BM_MoneyMaker.pla
Follow me on Twitter Reply With Quote




Last Updated on April 3, 2014


© 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