Scaling out Script....Bug?

Questions about MultiCharts and user contributed studies.
Guest

Scaling out Script....Bug?

Postby Guest » 23 Aug 2007

This is a simple moving average cross system with a scaling out exit of 2 contracts, so if youre long 2 you would exit 1 at a profit target then let the other one run...When I aplpy it to MC it looks fine on the chart but when I go to view the strategy report it either freezes MC or if I see the report it shows a loop of trading that restarts after the end of data with a weird amount of contracts like over a million....I change the fixed contracts in the strategy property window to 2 and everything looks fine except when i go to view the report.....Is it the script or MC not being able to calculate it? Any help would be appreciated....


Code: Select all

{****MOVINGAVERAGE CROSS ENTRY****}
inputs: Price( Close ), FastLength( 9 ), SlowLength( 18 ) ;
variables: FastAvg( 0 ), SlowAvg( 0 ) ;

FastAvg = AverageFC( Price, FastLength ) ;
SlowAvg = AverageFC( Price, SlowLength ) ;

if CurrentBar > 1   and FastAvg crosses over SlowAvg then
   Buy ( "MA2CrossLE" ) next bar at market ;
   

if CurrentBar > 1 and FastAvg crosses under SlowAvg then
   Sell Short ( "MA2CrossSE" ) next bar at market ;   


{****SCALING OUT EXITS****}
   
inputs: 
     TargetAmt1( 20 points ) ,             
     FullPosition( 2 { contracts } ) , 
     HalfPosition( 1 { contract } ) ; 
 
variables: 
     ProfTarget1( 0 ) , 
     ProfTarget2( 0 ) ; 
 
if MarketPosition = 1 and BarsSinceEntry = 0 then 
     begin 
     ProfTarget1 = EntryPrice + TargetAmt1 ;   
     end ;   
if MarketPosition = 1 then
     begin 
     if CurrentShares = FullPosition then 
         sell HalfPosition contracts next bar at ProfTarget1 limit ;         
         end;
         
if MarketPosition = -1 and BarsSinceEntry = 0 then 
     begin 
     ProfTarget1 = EntryPrice - TargetAmt1 ;   
        end;     
if MarketPosition = -1 then
     begin 
     if CurrentShares = FullPosition then 
         buy to cover HalfPosition contracts next bar at ProfTarget1 limit ;         
         
          end;
 
   setexitonclose;        
 

Guest

Postby Guest » 23 Aug 2007

By the way Im applying this strategy to intraday bars, 5 min., 10 min. etc...

Guest

Postby Guest » 23 Aug 2007

here is an image of of the strategy report where things go bad........
Attachments
report.png
report
report.png (39.21 KiB) Viewed 241 times

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 24 Aug 2007

Hello,

This is a confirmed bug. It's fixed in the next beta version which is to be released next week.

Guest

Postby Guest » 24 Aug 2007

Thankyou...Looking forward to the next release!


Return to “MultiCharts”