Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,767 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
MMI and Thinkscript - Think or Swim #475451
12/10/18 22:56
12/10/18 22:56
Joined: Oct 2018
Posts: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
AZ
I'm trying to convert the lite C version of MMI into thinkscript so that I can use MMI with think or swim.

I've coded up the following but I'm not 100% sure it's doing what it's supposed to do as the iterator logic is different in thinkscript than anything I've seen. Thinkscript uses fold instead of for loops. See https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/fold.html

The trickiest part was calculating nh and nl as these are iterated for each price in the lookback series.

The input mmiLength section lets the user define how far back you want to look. I choose 150 as a default value based off of a previous post from JCL that said 100-200 bars is a good compromise.

Here's my solution. Anyone see any problems with it?

input mmiLength = 150;
def m = Median(close, mmiLength);

def nh = fold i = 1 to mmiLength+1 with p = 0 do if close[i] > m and close[i] > getValue(close, i + 1) then p+1 else p+0;

def nl = fold j = 1 to mmiLength+1 with q = 0 do if close[j] < m and close[j] < getValue(close, j + 1) then q+1 else q+0;

plot mmi= 100*(nl+nh)/(mmiLength-1);

Re: MMI and Thinkscript - Think or Swim [Re: chsmac85] #475452
12/11/18 00:45
12/11/18 00:45
Joined: Aug 2018
Posts: 101
O
OptimusPrime Offline
Member
OptimusPrime  Offline
Member
O

Joined: Aug 2018
Posts: 101
Hi chsmac85:

This is a Zorro specific forum.. We are trying to learn and improve our use of Lite-C specifically. Did you try a similiar forum specifically for ThinkorSwim coding?


Thanks so much,

OptimusPrime

Re: MMI and Thinkscript - Think or Swim [Re: OptimusPrime] #475453
12/11/18 02:36
12/11/18 02:36
Joined: Oct 2018
Posts: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
AZ
sorry I didn't. I considered MMI to be a part of the zorro family and posted in the brokers section given think or swim is a platform for a very popular broker. But that's fine, I can look for help elsewhere.


Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1