NexusFi: Find Your Edge


Home Menu

 





MultiCharts Coding Help


Discussion in MultiCharts

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




 
Search this Thread

MultiCharts Coding Help

  #1 (permalink)
 
vitrader's Avatar
 vitrader 
New York, New York, United States
 
Experience: Beginner
Platform: TOS
Trading: Options
Posts: 53 since Jul 2015
Thanks Given: 13
Thanks Received: 7

Below is my code for Multicharts:
--
inputs: UpColor(Green), DnColor(Red), BarWidth(1) , CompBars(5) , start.time(0930) , end.time(1600);

vars: haClose(0), haOpen(0), color(0);

if BarNumber = 1 then
begin
haOpen = open;
haClose = (O+H+L+C)/4;
end;

if BarNumber > 1 then
begin
haClose = (O+H+L+C)/4;
haOpen = (haOpen [1] + haClose [1])/2 ;
end;
{ ................................................................................ }
if haClose > haOpen then color = UpColor
else color = DnColor;

for value1 = 1 to CompBars
begin
if haOpen <= MaxList(haOpen[value1],haClose[value1]) and
haOpen >= MinList(haOpen[value1],haClose[value1]) and
haClose <= MaxList(haOpen[value1],haClose[value1]) and
haClose >= MinList(haOpen[value1],haClose[value1]) then
color = color[value1];
end;
{ ................................................................................ }

{plotPB(haOpen,haClose,"heikin-ashi",color);
plotPB(High,Low,"heikin-ashi",color);
SetPlotWidth(1,BarWidth);
SetPlotColor(1,color);
end;}
{ ................................................................................ }

//initial beginning
If time >= start.time and time <= end.time and MarketPosition = 0 then begin

//long entry
if haClose > haOpen then begin
Buy 100 shares next bar at Market;
If MarketPosition = 1 and haClose < haOpen then begin
Sell ("close") 100 shares next bar at Market;
End;
end;

//short entry
if haClose < haOpen then begin
Sellshort ("enter short") 100 shares next bar at Market;
if MarketPosition = -1 and haClose > haOpen then begin
buytocover ("close") 100 shares next bar at Market;
end;
end;
End;
--
For some reason, the code isn't executing orders despite it being compiled successfully. If anyone can offer any help, it would be greatly appreciated.

Thank you.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 
sptrader's Avatar
 sptrader 
Colorado
 
Experience: Advanced
Platform: MultiCharts
Broker: IB & Iqfeed
Trading: ES , CL
Posts: 535 since Apr 2010
Thanks Given: 1,097
Thanks Received: 701

You have MarketPosition = 0 as a condition , so once you open a position, it will never close or take another position..

Reply With Quote
Thanked by:
  #3 (permalink)
 
vitrader's Avatar
 vitrader 
New York, New York, United States
 
Experience: Beginner
Platform: TOS
Trading: Options
Posts: 53 since Jul 2015
Thanks Given: 13
Thanks Received: 7



sptrader View Post
You have MarketPosition = 0 as a condition , so once you open a position, it will never close or take another position..

Thank you.

Started this thread Reply With Quote




Last Updated on April 21, 2016


© 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